﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'table', 'common', 'tablePlug', "layer"], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layer = layui.layer,
            common = layui.common;
        //加载数据
        var loading = layer.load(0, { shade: false });
        var value = $.request("value");
        var name = $.request("name");
        var rendertree = function () {
            common.rendertreetable({
                elem: '#currentTableId',
                url: '/SystemManage/Organize/GetTreeGridJson',
                height: 'full-50',
                toolbar: false,//工具栏
                id: 'currentTableId',
                sqlkey: 'F_Id',//数据库主键
                cols: [[
                    { type: 'checkbox' },
                    { field: 'F_Id', title: 'ID', fixed: "left", hide: true, hideAlways: true },
                    { field: 'F_FullName', title: '名称', width: 120 },
                    { field: 'F_EnCode', title: '编号', width: 120 },
                    {
                        field: 'F_CategoryId', title: '分类', width: 120,
                        templet: function (d) {
                            if (d.F_CategoryId == "Group") {
                                return "集团";
                            } else if (d.F_CategoryId == "Company") {
                                return "公司";
                            } else if (d.F_CategoryId == "Department") {
                                return "部门";
                            } else if (d.F_CategoryId == "WorkGroup") {
                                return "小组";
                            } else {
                                return d.F_CategoryId;
                            }
                        }
                    },
                    {
                        field: 'F_EnabledMark', title: '有效', width: 60,
                        templet: function (d) {
                            if (d.F_EnabledMark == true) {
                                return "<input type='checkbox' checked='' lay-skin='primary' name='true' valuer='true'>";
                            } else {
                                return "<input type='checkbox' name='false'  lay-skin='primary' valuer='false'>";
                            }
                        }
                    }
                ]],
                done: function () {
                    //关闭加载
                    layer.closeAll('loading');
                }
            });
        }
        rendertree();
        // 监听提交操作
        form.on('submit(saveBtn)', function (data) {
            var checkStatus = table.checkStatus("currentTableId").data;
            var pvalue = [];
            var pname = [];
            for (var i = 0; i < checkStatus.length; i++) {
                pvalue.push(checkStatus[i].F_Id);
                pname.push(checkStatus[i].F_FullName);
            }
            if (!!pvalue) {
                parent.$('#' + value).val(pvalue.join(","));
            }
            if (!!pname) {
                parent.$('#' + name).val(pname.join(","));
            }
            common.modalClose();
            return false;
        });
    });
</script>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset layui-hide">
            @*<legend>搜索信息</legend>*@
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">关键字:</label>
                            <div class="layui-input-inline">
                                <input type="text" id="txt_keyword" name="txt_keyword" autocomplete="off" class="layui-input" placeholder="">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon">&#xe615;</i> 搜 索</button>
                        </div>
                    </div>
                    <div class="layui-form-item layui-hide">
                        <button class="layui-btn" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                    </div>
                </form>
            </div>
        </fieldset>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>